package 笔试.同城58;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/12-16:40
 * @version:1.0
 * @function:
 */
public class Main05 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String s1 = s.replaceAll(" ","");
        String s3 = s1.substring(1, s1.length() - 1);
        String[] split = s3.split(",");
        int length = split.length/2;
        int[][] arr = new int[length][2];
        for (int i = 0; i < length; i++) {
            arr[i][0] = Integer.parseInt(split[i*2].substring(1));
            arr[i][1] = Integer.parseInt(split[i*2+1].substring(0,1));
        }
        int res = fun(arr);
        System.out.println(res);
    }
    private static int fun(int[][] arr) {
        Arrays.sort(arr,(a,b)->a[0]-b[0]);
        int res =0,n = arr.length;
        if (n==0) return res;
        int [] cur = arr[0];
        for (int i = 1; i < n; i++) {
            if (arr[i][0]<cur[1])
            {
                res++;
                cur[1] = Math.min(arr[i][1],cur[1]);
            }else
                cur = arr[i];
        }
        return res;
    }
}
